package com.mapper;

import com.Dto.SupervisorInfoDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
@Mapper
public interface SupervisorInfoMapper {

    /**督导个人信息，包括督导姓名，今日援助数，今日援助时长
     *
     * @param supervisorId
     * @return
     */
    @Select("SELECT s.name AS supervisorName, COUNT(gs.id) AS todayAssistance,\n" +
            "       SEC_TO_TIME(SUM(TIME_TO_SEC(gs.guidance_duration))) AS todayDuration\n" +
            "FROM supervisor s\n" +
            "         LEFT JOIN guidance_session gs ON gs.supervisor_id = s.id AND DATE(gs.time) = CURDATE()\n" +
            "WHERE s.id = #{supervisorId}\n" +
            "GROUP BY s.id;\n" )
    List<SupervisorInfoDto> findSupervisorInfo(@Param("supervisorId") Integer supervisorId);

}
